Hello, |
Re: Public View To answer your question, the DOORS super-user "Administrator" will need to plow through the views and provide "Everyone else" "RMCD" or "RMCDA" access. That is not hard with a script. It seems better to me though to just change the view to have "Inherited" access. Better still would be for there to be a set of Project approved views that only the Project admins may modify. -Louie |
Re: Public View
Hello,
// List Public Views
/*
Lists public views found in modules.
Reports public views found in modules together with the owner
and their email address.
24-MAY-2011 Tony Goodman
*/
pragma runLim, 0
DB dbMain = null
DBE dbeResults = null
Buffer buf = create
/*********************************
getAccessRecord
*********************************/
string getAccessRecord(AccessRec ar)
{
string r = ((read ar) ? "R" : "")
string m = ((modify ar) ? "M" : "")
string c = ((create ar) ? "C" : "")
string d = ((delete ar) ? "D" : "")
string a = ((control ar) ? "A" : "")
string accessStr = r m c d a ""
if (null accessStr){accessStr = "None"}
return(accessStr)
}
/*********************************
isPublic
*********************************/
bool isPublic(View v, string &uName)
{
AccessRec ar = null
int count = 0
bool def = false
for ar in v do
{
//if no user or group assigned to AR, then must be the default "Everyone else" group
uName = username ar
if(null uName)
{
uName = "Administrator"
if(getAccessRecord(ar) != "None"){def = true}
}
}
return(def)
}
/*********************************
getPublicViews
*********************************/
void getPublicViews(string mName, Buffer resBuf)
{
Module m = null
string vn = ""
string uName = ""
bool noneFound = true
m = read(mName, false)
if (null m)
{
resBuf += "ERROR: Failed to open module " mName ".\n"
return
}
(current ModuleRef__) = m
for vn in views m do
{
if (isPublic(view vn, uName))
{
resBuf += name(m) " has public view \"" vn "\" owned by " uName ".\n"
noneFound = false
View v = view vn
unsetAll (v)
set (v, control | delete, "") // give everyone control permissions
}
}
if (noneFound)
{
resBuf += name(m) " does not have any public views.\n"
}
close(m)
}
/*********************************
doRun
*********************************/
void doRun(DB db)
{
Item i
setempty(buf)
int pCount = 0
int pLimit = 0
for i in current Folder do
{
if (type(i) != "Formal") continue
pLimit++
}
if (pLimit == 0)
{
buf += "No modules found.\n"
}
else
{
//buf += pLimit " modules found.\n"
if (!confirm("You are about to search for public views in " pLimit " modules\nAre you sure you want to continue?"))
{
buf += "Command aborted by user.\n"
}
else
{
progressStart(dbMain, "Checking modules", "Checking modules", pLimit)
for i in current Folder do
{
if (type(i) != "Formal") continue
pCount++
progressRange("Checking module " pCount " of " pLimit ".", pCount, pLimit)
getPublicViews(fullName(i), buf)
}
progressStop()
}
}
set(dbeResults, buf)
}
/*********************************
listPublicViews
*********************************/
void listPublicViews()
{
dbMain = create(dbExplorer, "List Public Views", styleCentered|styleFloating)
label(dbMain, "This utility allows you identify public views, and their owners, contained in modules below the current folder.")
field(dbMain, "Folder:", fullName(current Folder), 50, true)
dbeResults = text(dbMain, "Results:", "", 600, 150, true)
apply(dbMain, "Run", doRun)
realize(dbMain)
show(dbMain)
}
/*********************************
MAIN
*********************************/
listPublicViews()
|
Re: Public View SystemAdmin - Wed Jan 09 09:43:24 EST 2013
Hello,
// List Public Views
/*
Lists public views found in modules.
Reports public views found in modules together with the owner
and their email address.
24-MAY-2011 Tony Goodman
*/
pragma runLim, 0
DB dbMain = null
DBE dbeResults = null
Buffer buf = create
/*********************************
getAccessRecord
*********************************/
string getAccessRecord(AccessRec ar)
{
string r = ((read ar) ? "R" : "")
string m = ((modify ar) ? "M" : "")
string c = ((create ar) ? "C" : "")
string d = ((delete ar) ? "D" : "")
string a = ((control ar) ? "A" : "")
string accessStr = r m c d a ""
if (null accessStr){accessStr = "None"}
return(accessStr)
}
/*********************************
isPublic
*********************************/
bool isPublic(View v, string &uName)
{
AccessRec ar = null
int count = 0
bool def = false
for ar in v do
{
//if no user or group assigned to AR, then must be the default "Everyone else" group
uName = username ar
if(null uName)
{
uName = "Administrator"
if(getAccessRecord(ar) != "None"){def = true}
}
}
return(def)
}
/*********************************
getPublicViews
*********************************/
void getPublicViews(string mName, Buffer resBuf)
{
Module m = null
string vn = ""
string uName = ""
bool noneFound = true
m = read(mName, false)
if (null m)
{
resBuf += "ERROR: Failed to open module " mName ".\n"
return
}
(current ModuleRef__) = m
for vn in views m do
{
if (isPublic(view vn, uName))
{
resBuf += name(m) " has public view \"" vn "\" owned by " uName ".\n"
noneFound = false
View v = view vn
unsetAll (v)
set (v, control | delete, "") // give everyone control permissions
}
}
if (noneFound)
{
resBuf += name(m) " does not have any public views.\n"
}
close(m)
}
/*********************************
doRun
*********************************/
void doRun(DB db)
{
Item i
setempty(buf)
int pCount = 0
int pLimit = 0
for i in current Folder do
{
if (type(i) != "Formal") continue
pLimit++
}
if (pLimit == 0)
{
buf += "No modules found.\n"
}
else
{
//buf += pLimit " modules found.\n"
if (!confirm("You are about to search for public views in " pLimit " modules\nAre you sure you want to continue?"))
{
buf += "Command aborted by user.\n"
}
else
{
progressStart(dbMain, "Checking modules", "Checking modules", pLimit)
for i in current Folder do
{
if (type(i) != "Formal") continue
pCount++
progressRange("Checking module " pCount " of " pLimit ".", pCount, pLimit)
getPublicViews(fullName(i), buf)
}
progressStop()
}
}
set(dbeResults, buf)
}
/*********************************
listPublicViews
*********************************/
void listPublicViews()
{
dbMain = create(dbExplorer, "List Public Views", styleCentered|styleFloating)
label(dbMain, "This utility allows you identify public views, and their owners, contained in modules below the current folder.")
field(dbMain, "Folder:", fullName(current Folder), 50, true)
dbeResults = text(dbMain, "Results:", "", 600, 150, true)
apply(dbMain, "Run", doRun)
realize(dbMain)
show(dbMain)
}
/*********************************
MAIN
*********************************/
listPublicViews()
I believe the rules are; in order of precedence:
bool isPublic(View v, string &uName)
{
AccessRec ar = null
bool def = false
for ar in v do
{
//if no user or group assigned to AR, then must be the default "Everyone else" group
uName = username ar
if(null uName)
{
if(getAccessRecord(ar) != "None"){def = true}
}
}
return(def)
}
|
Re: Public View llandale - Wed Jan 09 16:52:00 EST 2013 I believe the rules are; in order of precedence:
bool isPublic(View v, string &uName)
{
AccessRec ar = null
bool def = false
for ar in v do
{
//if no user or group assigned to AR, then must be the default "Everyone else" group
uName = username ar
if(null uName)
{
if(getAccessRecord(ar) != "None"){def = true}
}
}
return(def)
}
I note that since the Administrator has default RMCDA to EVERYTHING, there is no need nor should never be any AccessRecord named "Administrator". I wonder what it could possibly mean. -Louie |
Re: Public View SystemAdmin - Wed Jan 09 09:43:24 EST 2013
Hello,
// List Public Views
/*
Lists public views found in modules.
Reports public views found in modules together with the owner
and their email address.
24-MAY-2011 Tony Goodman
*/
pragma runLim, 0
DB dbMain = null
DBE dbeResults = null
Buffer buf = create
/*********************************
getAccessRecord
*********************************/
string getAccessRecord(AccessRec ar)
{
string r = ((read ar) ? "R" : "")
string m = ((modify ar) ? "M" : "")
string c = ((create ar) ? "C" : "")
string d = ((delete ar) ? "D" : "")
string a = ((control ar) ? "A" : "")
string accessStr = r m c d a ""
if (null accessStr){accessStr = "None"}
return(accessStr)
}
/*********************************
isPublic
*********************************/
bool isPublic(View v, string &uName)
{
AccessRec ar = null
int count = 0
bool def = false
for ar in v do
{
//if no user or group assigned to AR, then must be the default "Everyone else" group
uName = username ar
if(null uName)
{
uName = "Administrator"
if(getAccessRecord(ar) != "None"){def = true}
}
}
return(def)
}
/*********************************
getPublicViews
*********************************/
void getPublicViews(string mName, Buffer resBuf)
{
Module m = null
string vn = ""
string uName = ""
bool noneFound = true
m = read(mName, false)
if (null m)
{
resBuf += "ERROR: Failed to open module " mName ".\n"
return
}
(current ModuleRef__) = m
for vn in views m do
{
if (isPublic(view vn, uName))
{
resBuf += name(m) " has public view \"" vn "\" owned by " uName ".\n"
noneFound = false
View v = view vn
unsetAll (v)
set (v, control | delete, "") // give everyone control permissions
}
}
if (noneFound)
{
resBuf += name(m) " does not have any public views.\n"
}
close(m)
}
/*********************************
doRun
*********************************/
void doRun(DB db)
{
Item i
setempty(buf)
int pCount = 0
int pLimit = 0
for i in current Folder do
{
if (type(i) != "Formal") continue
pLimit++
}
if (pLimit == 0)
{
buf += "No modules found.\n"
}
else
{
//buf += pLimit " modules found.\n"
if (!confirm("You are about to search for public views in " pLimit " modules\nAre you sure you want to continue?"))
{
buf += "Command aborted by user.\n"
}
else
{
progressStart(dbMain, "Checking modules", "Checking modules", pLimit)
for i in current Folder do
{
if (type(i) != "Formal") continue
pCount++
progressRange("Checking module " pCount " of " pLimit ".", pCount, pLimit)
getPublicViews(fullName(i), buf)
}
progressStop()
}
}
set(dbeResults, buf)
}
/*********************************
listPublicViews
*********************************/
void listPublicViews()
{
dbMain = create(dbExplorer, "List Public Views", styleCentered|styleFloating)
label(dbMain, "This utility allows you identify public views, and their owners, contained in modules below the current folder.")
field(dbMain, "Folder:", fullName(current Folder), 50, true)
dbeResults = text(dbMain, "Results:", "", 600, 150, true)
apply(dbMain, "Run", doRun)
realize(dbMain)
show(dbMain)
}
/*********************************
MAIN
*********************************/
listPublicViews()
You broke my script!
/*********************************
isPublic
*********************************/
bool isPublic(View v, string &uName, string &uEmail)
{
AccessRec ar = null
User u = null
int count = 0
bool def = false
for ar in v do
{
count++
}
if (count == 2)
{
for ar in v do
{
if (getAccessRecord(ar) == "R")
{
def = true
}
else if (getAccessRecord(ar) == "RMCDA")
{
uName = username ar
if (uName "" != "")
{
u = find(uName)
}
if (!null u)
{
uEmail = u.email
}
}
}
return(def && !null u)
}
return(false)
}
|
Re: Public View Tony_Goodman - Thu Jan 10 05:26:31 EST 2013
You broke my script!
/*********************************
isPublic
*********************************/
bool isPublic(View v, string &uName, string &uEmail)
{
AccessRec ar = null
User u = null
int count = 0
bool def = false
for ar in v do
{
count++
}
if (count == 2)
{
for ar in v do
{
if (getAccessRecord(ar) == "R")
{
def = true
}
else if (getAccessRecord(ar) == "RMCDA")
{
uName = username ar
if (uName "" != "")
{
u = find(uName)
}
if (!null u)
{
uEmail = u.email
}
}
}
return(def && !null u)
}
return(false)
}
-Jim |
Re: Public View Tony_Goodman - Thu Jan 10 05:26:31 EST 2013
You broke my script!
/*********************************
isPublic
*********************************/
bool isPublic(View v, string &uName, string &uEmail)
{
AccessRec ar = null
User u = null
int count = 0
bool def = false
for ar in v do
{
count++
}
if (count == 2)
{
for ar in v do
{
if (getAccessRecord(ar) == "R")
{
def = true
}
else if (getAccessRecord(ar) == "RMCDA")
{
uName = username ar
if (uName "" != "")
{
u = find(uName)
}
if (!null u)
{
uEmail = u.email
}
}
}
return(def && !null u)
}
return(false)
}
Hi Tony, Your scripts are excellent and I've used many of them for various tasks. I did discover one corner case where this script produces an error. Apparently, if a user created a view and that user is no longer in the database, the script will toss an error at the line u = find (uName) and later lines in the script that rely on that line. Should their be a break statement for that corner case? |
Re: Public View Chris Annal - Mon Jul 28 11:40:56 EDT 2014 Hi Tony, Your scripts are excellent and I've used many of them for various tasks. I did discover one corner case where this script produces an error. Apparently, if a user created a view and that user is no longer in the database, the script will toss an error at the line u = find (uName) and later lines in the script that rely on that line. Should their be a break statement for that corner case? Run the script as the "Administrator". Seems to me you'd need to do that anyway, adding your "DB Admins" group to all the views. And folders modules that are not Inherited. |
Re: Public View llandale - Mon Jul 28 16:44:58 EDT 2014 Run the script as the "Administrator". Seems to me you'd need to do that anyway, adding your "DB Admins" group to all the views. And folders modules that are not Inherited. You're right about a script that intends to modify the access to a View (if the user who created it didn't bother to make any changes to the default access), However, this script is simply listing those views that fall into that category - so you don't have to be an Administrator to run it. In other words, a user named "vCreator" created a Public View named "MyView". The default access to that view is: vCreator = RMCDA Everyone Else = R ...and you have to be an Administrator in order to change that access if user vCreator is no longer in the database. What I'm saying is that if user vCreator is no longer in the database, the script fails at the line: u = find (uName) This is regardless of who runs the script. |
Re: Public View ChrisAnnal - Mon Jul 28 17:15:37 EDT 2014 You're right about a script that intends to modify the access to a View (if the user who created it didn't bother to make any changes to the default access), However, this script is simply listing those views that fall into that category - so you don't have to be an Administrator to run it. In other words, a user named "vCreator" created a Public View named "MyView". The default access to that view is: vCreator = RMCDA Everyone Else = R ...and you have to be an Administrator in order to change that access if user vCreator is no longer in the database. What I'm saying is that if user vCreator is no longer in the database, the script fails at the line: u = find (uName) This is regardless of who runs the script. I found a workaround that works for my purposes, anyway. I just created a string to catch "uName" instead of looking for a user from the database. Since the email portion is also using a user from the database, I worked around that by hard-coding the email address. It assumes "ViewOwner" is the name of the user without actually verifying it in the database. This avoids the error when a user has been disabled or purged from the database...
*********************************/
for ar in v do
if (count == 2)
if (uName "" != "")
if (!null u)
return(def && !null u)
return(false) |
Re: Public View ChrisAnnal - Mon Jul 28 17:15:37 EDT 2014 You're right about a script that intends to modify the access to a View (if the user who created it didn't bother to make any changes to the default access), However, this script is simply listing those views that fall into that category - so you don't have to be an Administrator to run it. In other words, a user named "vCreator" created a Public View named "MyView". The default access to that view is: vCreator = RMCDA Everyone Else = R ...and you have to be an Administrator in order to change that access if user vCreator is no longer in the database. What I'm saying is that if user vCreator is no longer in the database, the script fails at the line: u = find (uName) This is regardless of who runs the script. I check for the existence first with one or both of these: bool existsGroup(string name)
bool existsUser(string name)
You can also trap the error: string Name = "zz" Curious, "u" comes back non-null so you need ErrMess. -Louie |